package main

import (
	"flag"
	"fmt"
	"strings"
	_ "tosServer/internal/pkg/config"
	"tosServer/internal/pkg/db"

	"gorm.io/gen"
)

func main() {

	var table string

	flag.StringVar(&table, "table", "", "表名，多个,分割")
	flag.Parse()

	if table == "" {
		panic("table is empty")
	}

	tables := strings.Split(table, ",")

	g := gen.NewGenerator(gen.Config{
		OutPath:           "./internal/model",
		ModelPkgPath:      "model",
		FieldCoverable:    true,
		FieldWithTypeTag:  true,
		FieldWithIndexTag: true,
	})

	g.UseDB(db.Db())

	for _, t := range tables {
		g.GenerateModel(t)
		fmt.Printf("%s success", t)
	}

	g.Execute()

	fmt.Println("execute success")

}
